package com.ww.microrpc.loadbalancer;

import com.netflix.client.DefaultLoadBalancerRetryHandler;
import com.netflix.client.config.IClientConfig;
import com.netflix.loadbalancer.ILoadBalancer;
import com.ww.microrpc.netty.NettyClientConfig;
import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory;

public class RetryableWrpcLoadBalancer extends RpcLoadBalancer {

    private final LoadBalancedRetryFactory loadBalancedRetryFactory;

    public RetryableWrpcLoadBalancer(ILoadBalancer lb,
                                     IClientConfig clientConfig,
                                     LoadBalancedRetryFactory loadBalancedRetryFactory,
                                     NettyClientConfig nettyClientConfig) {

        super(lb, clientConfig, nettyClientConfig);
        this.loadBalancedRetryFactory = loadBalancedRetryFactory;
        this.setRetryHandler(new DefaultLoadBalancerRetryHandler(clientConfig));
    }
}
